package org.huawei260.OD260;

import java.util.Scanner;

/**
 * @Auther: qingle
 * @Date: 2024/8/19-17:38
 * @Description:
 * 输入一个英文文章片段，
 * 翻转指定区域的单词顺序，
 * 标点符号和普通字母一样处理，
 * 例如输入字符串
 * I am a developer.
 * [0,3]
 * 则输出
 * developer. a am I
 * @version: 1.0
 */
public class O0007_单词反转 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String sentence = sc.nextLine();
		int n = sc.nextInt();
		int m = sc.nextInt();

		System.out.println(reverseWordsInRegion(sentence, n, m));
	}


	public static String reverseWordsInRegion(String sentence, int start, int end) {
		// 将句子按空格分割成单词数组
		String[] words = sentence.split(" ");

		// 翻转指定区域的单词
		reverseArray(words, start, end);

		// 将翻转后的单词数组重新组合成字符串
		StringBuilder reversedSentence = new StringBuilder();
		for (int i = 0; i < words.length; i++) {
			reversedSentence.append(words[i]);
			if (i < words.length - 1) {
				reversedSentence.append(" ");
			}
		}

		return reversedSentence.toString();
	}

	private static void reverseArray(String[] array, int start, int end) {
		while (start < end) {
			// 交换数组中的元素
			String temp = array[start];
			array[start] = array[end];
			array[end] = temp;
			start++;
			end--;
		}
	}
}
